<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<%--
  Created by IntelliJ IDEA.
  User: 18134216985
  Date: 2024-04-13
  Time: 11:57
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="/webjars/layui/2.6.8/css/layui.css">
    <script src="/webjars/layui/2.6.8/layui.js"></script>
</head>
<body>
<div class="layui-collapse">
    <div class="layui-colla-item">
        <div class="layui-colla-title">停车费</div>
        <div class="layui-colla-content">
            <table class="layui-hide" id="ID-stopcartable-demo-data" lay-filter="stopcarTable"></table>

        </div>
        <script type="text/html" id="stopcarbtn">
            <button class='layui-btn layui-btn-sm layui-btn-normal' lay-event='stopcarpay'>缴费</button>
        </script>
    </div>
    <script>
        let $=layui.$;
        let table=layui.table;
        layui.use(["table","laydate"],function (){
            table.render({
                id:'stopcar',
                elem:'#ID-stopcartable-demo-data',
                url:"/Repairquotation/OwnerSelectStopCarByOwnerphone?ownerphone="+${sessionScope.loginUser.ownerphone},
                page:true,
                cols:[[
                    {field:'number',align: 'center',type:'numbers',title:"编号"},
                    {field:'id',align: 'center',hide:true,title:"序号"},
                    {align: 'center',field: 'ownername',title: '姓名'},
                    {align: 'center',field: 'ownerphone',title: '联系电话'},
                    {align: 'center',field: 'parklotname',title: '车位'},
                    {align: 'center',field: 'parkname',title: '停车场'},
                    {align: 'center',field: 'starttime',title: '开始时间'},
                    {align: 'center',field: 'endtime',title: '结束时间'},
                    {align: 'center',field: 'money',title: '单价'},
                    {align: 'center',field: 'zomoney',title: '总价'},
                    {align: 'center',title: '操作',toolbar:"#stopcarbtn"},

                ]]
            })

        })
        table.on("tool(stopcarTable)",function (obj) {
            if (obj.event == "stopcarpay") {
                stopcarpay(obj);
            }

            function stopcarpay(obj) {
                layui.layer.open({
                    type: 0,
                    icon: 3,
                    area: ["250px", "200px"],
                    title: "提示",
                    content: "确定缴费？",
                    btn: ["确定", "取消"],
                    yes() {
                        $.post("/Repairquotation/UpdateIsNoById?id=" + obj.data.id).then(({msg}) => {
                            layui.layer.close(layui.layer.index);
                            layui.layer.msg(msg);
                            layui.table.reload('stopcar');
                        })
                        $.post("/Repairquotation/addQuotation").then(({msg}) => {
                            layui.layer.close(layui.layer.index);
                            layui.layer.msg(msg);
                            layui.table.reload('stopcar');
                        })

                    }
                })
            }
        })
    </script>
    <div class="layui-colla-item">
        <%------------------------维修费------------------------------------------------------------------------------------------------%>
        <div class="layui-colla-title">维修费</div>
            <script type="text/html" id="weixiubtn">
                <button class='layui-btn layui-btn-sm layui-btn-normal' lay-event='weixiupay'>缴费</button>
            </script>
        <div class="layui-colla-content">
            <table class="layui-hide" id="ID-weixiutable-demo-data" lay-filter="weixiuTable"></table>
        </div>
<script>
    layui.use(["table","laydate"],function (){
        table.render({
            id:'weixiu',
            elem:'#ID-weixiutable-demo-data',
            url:"/Repairquotation/ownerSelectQuotation?ownerid="+${sessionScope.loginUser.id},
            page:true,
            cols:[[
                {field:'number',align: 'center',type:'numbers',title:"编号"},
                {field:'id',align: 'center',hide:true,title:"序号"},
                {align: 'center',field: 'ownerid',title: '报修人',templet(d){
                    return d.owners==null?"-":d.owners.ownername
                    }},
                {align: 'center',field: 'phone',title: '联系电话'},
                {align: 'center',field: 'money',title: '价格'},
                {align: 'center',field: 'repairstype',title: '报修类型'},
                {align: 'center',field: 'position',title: '报修位置'},
                {align: 'center',field: 'plotid',title: '小区名称',templet(d) {
                        console.log(d.plot)
                        return d.plot==null?"-":d.plot.plotname;
                    }},
                {align: 'center',field: 'createtime',title: '时间'},
                {align: 'center',title: '操作',toolbar:"#weixiubtn"},

            ]]
        })

    })
    table.on("tool(weixiuTable)",function (obj){
        if(obj.event=="weixiupay"){
            weixiupay(obj.data.id);
        }
    })
    function weixiupay(id){
        layui.layer.open({
            type:0,
            icon:3,
            area:["250px","200px"],
            title:"提示",
            content:"完成缴费？",
            btn:["确定","取消"],
            yes(){
                $.post("/Repairquotation/OwnerUpdateQuotationState?id="+id).then(({msg})=>{
                    layui.layer.close(layui.layer.index);
                    layui.layer.msg(msg);
                    layui.table.reload('weixiu');
                })
            }
        })


    }
</script>
    </div>
<%-----------------------------其他费用---------------------------------%>
            <div class="layui-colla-item">
                <div class="layui-colla-title">其他缴费</div>
                <div class="layui-colla-content">
                    <table class="layui-hide" id="ID-othertable-demo-data" lay-filter="otherTable"></table>
                </div>
                <script type="text/html" id="otherbtn">
                    <button class='layui-btn layui-btn-sm layui-btn-normal' lay-event='otherpay'>缴费</button>
                </script>
            </div>
            <script>
               layui.use("table",function (){
                   table.render({
                       id:'other',
                       elem:'#ID-othertable-demo-data',
                       url:"/Repairquotation/selectPayByOwnerid?ownerid="+${sessionScope.loginUser.id},
                       cols:[[
                           {align: 'center',field:'id',title:'编号'},
                           {align: 'center',field: 'itemid',title: '缴费项目',templet(d){
                               return d.item==null?"-":d.item.itemname
                               }},
                           {align: 'center',field: 'paymoney',title: '支付金额'},
                           {align: 'center',field: 'createtime',title: '生成时间'},
                           {align: 'center',field: 'notes',title: '备注'},
                           {align: 'center',title: '操作',toolbar:"#otherbtn"},

                       ]]
                   })
                   table.on("tool(otherTable)",function (obj){
                       if(obj.event=="otherpay"){
                           otherpay(obj.data.id);
                       }
                   })
               })

               function otherpay(id){
                    layui.layer.open({
                        type:0,
                        icon:3,
                        area:["250px","200px"],
                        title:"提示",
                        content:"完成缴费？",
                        btn:["确定","取消"],
                        yes(){
                            $.post("/Repairquotation/updatePay?id="+id).then(({msg})=>{
                                layui.layer.close(layui.layer.index);
                                layui.layer.msg(msg);
                                layui.table.reload("other")
                            })
                        }
                    })
               }
            </script>
    </div>
</div>
</body>
</html>
